<template>
  <div :class="type == '1' ? 'current' : ''">
    <div v-for="(item, index) in copyInterceptList" :key="index" class="coupon_box">
      <div class="coupon">
        <div class="coupon-left">
          <div v-if="item.vouType == 'VOU3'" class="cash">
            ¥<span>{{ item.amtAcount }}</span>
            <div class="condition">满{{ item.jelimit }}元使用</div>
          </div>
          <div v-else class="discount">
            <span style="font-size: 30px; font-family: Impact">{{ item.vouDis }} </span>
            <span style="font-size: 13px">折</span>
          </div>
          <div class="vou_size">{{ vouType[item.vouType] }}</div>
        </div>
        <div class="coupon-con">
          <div>
            <ellipsis :length="20" tooltip>{{ item.name }}</ellipsis>
          </div>
          <a-tooltip placement="top">
            <template slot="title">
              <span>{{ item.pp }} </span>
            </template>
            <div>· 适用品牌：{{ item.pp }}</div>
          </a-tooltip>
          <div @click="interceptClick(index)" class="cursor">
            <span> {{ item.startDate }}-{{ item.validDate }}</span>
            <a-icon :type="item.falg ? 'up' : 'down'" style="color: #98999b" />
          </div>
        </div>
        <img src="../../../../assets/overdue.png" v-if="item.couponTag" class="overdue-img" />
      </div>
      <div class="coupon-bottom" v-if="item.falg">
        <div style="word-break:keep-all;">· 适用品牌：{{ item.pp }}</div>
        <div>· 使用说明：</div>
        <div v-html="item.memo">{{ item.memo }}</div>
      </div>
    </div>
    <a-modal title="优惠券" :width="440" :visible="visible" :height="655" centered @cancel="handleCancel" :footer="null">
      <div v-for="(item, index) in this.copyDiscountList" :key="index" style="width: 300px; margin: 0 auto">
        <div class="coupon">
          <div class="coupon-left">
            <div v-if="item.vouType == 'VOU3'" class="cash">
              ¥<span>{{ item.amtAcount }}</span>
              <div class="condition">满{{ item.jelimit }}元使用</div>
            </div>
            <div v-else class="discount">
              <span style="font-size: 30px; font-family: Impact">{{ item.vouDis }} </span>
              <span style="font-size: 13px">折</span>
            </div>
            <div class="vou_size">{{ vouType[item.vouType] }}</div>
          </div>
          <div class="coupon-con">
            <div>
              <ellipsis :length="20" tooltip>{{ item.name }}</ellipsis>
            </div>
            <a-tooltip placement="top">
              <template slot="title">
                <span>{{ item.pp }} </span>
              </template>
              <div>· 适用品牌：{{ item.pp }}</div>
            </a-tooltip>
            <div class="cursor" @click="falgClick(index)">
              <span> {{ item.startDate }}-{{ item.validDate }}</span>
              <a-icon :type="item.falg ? 'up' : 'down'" style="color: #98999b" />
            </div>
          </div>
          <img src="../../../../assets/overdue.png" v-if="item.couponTag" class="overdue-img" />
        </div>
        <div class="coupon-bottom" v-if="item.falg">
          <div style="word-break:keep-all;">· 适用品牌：{{ item.pp }}</div>
          <div>· 使用说明：</div>
          <div v-html="item.memo">{{ item.memo }}</div>
        </div>
      </div>
    </a-modal>
  </div>
</template>
<script>
import Vue from 'vue'
import { USER_INFO } from '@/store/mutation-types'
import { Ellipsis } from '../index'
export default {
  props: {
    type: {
      type: String,
      default: '',
      require: 0
    },
    // 默认展示数据
    interceptList: {
      type: Array,
      required: true
    },
    // 弹框数据
    discountList: {
      type: Array,
      required: true
    }
  },
  components: { Ellipsis },
  data() {
    return {
      visible: false,
      copyDiscountList: [],
      copyInterceptList: [],
      userInfo: Vue.ls.get(USER_INFO),
      vouType: {
        VOU3: '现金券',
        VOU4: '折扣券'
      }
    }
  },
  watch: {
    discountList(newVal, oldVal) {
      this.copyDiscountList = newVal
    },
    interceptList(newVal, oldVal) {
      this.copyInterceptList = newVal
    }
  },
  methods: {
    open() {
      this.visible = true
    },
    handleCancel() {
      this.visible = false
    },
    falgClick(index) {
      let list = JSON.parse(JSON.stringify(this.copyDiscountList))
      list[index].falg = !list[index].falg
      this.copyDiscountList = list
    },
    interceptClick(index) {
      let list = JSON.parse(JSON.stringify(this.copyInterceptList))
      list[index].falg = !list[index].falg
      this.copyInterceptList = list
    }
  }
}
</script>
<style lang="less" scoped>
.coupon {
  display: flex;
  overflow: hidden;
  border-radius: 5px;
  display: flex;
  padding: 15px 0px 0px 0px;
  box-shadow: 0px 8px 8px 0px rgba(0, 0, 0, 0.02);
  position: relative;
  margin-bottom: 20px;
  box-sizing: border-box;
  width: 300px;
  height: 102px;
}
.coupon-left {
  position: relative;
  width: 101px;
  // height: 102px;
  bottom: 0px;
  left: 0px;
  text-align: center;
  // width: 101px;
  span {
    font-size: 30px;
  }
  div {
    color: #327542;
    font-size: 11px;
    margin: 0 auto 4px;
  }
  .cash {
    padding-top: 2px;
    margin-bottom: 0;
  }
  .condition {
    line-height: 16px;
    margin-bottom: 4px;
    margin-top: -8px;
  }
}
.vou_size {
  color: #327542;
  font-size: 10px;
  width: 40px;
  line-height: 14px;
  background: #eaf1eb;
  border-radius: 2px;
  border: 1px solid #eaf1eb;
  text-align: center;
  margin-top: 4px;
}
.coupon-left::after {
  left: 86px;
  top: 82px;
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 100%;
  background: #f6f6f6;
}
.coupon-con {
  width: 199px;
  height: 87px;
  div:nth-child(2) {
    color: #666666;
    font-size: 11px;
    font-weight: 400;
    border-bottom: 1px solid #f6f6f6;
    padding-bottom: 12px;
    display: inline-block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    // max-width: 180px;
    width: 100%;
    padding-right: 20px;
    box-sizing: border-box;
  }
  div:first-child {
    font-size: 14px;
    font-weight: 600;
    color: #1c1c1c;
    margin-bottom: 5px;
  }
  div:last-child {
    font-size: 11px;
    font-weight: 400;
    color: #666666;
    // margin-top: 12px;
    display: flex;
    align-items: center;
    span {
      margin-right: 20px;
    }
  }
}
.coupon-bottom {
  background: #fff;
  box-shadow: 0px 8px 8px 0px rgba(0, 0, 0, 0.02);
  border-radius: 8px;
  font-size: 11px;
  font-weight: 400;
  color: #98999b;
  margin-top: 15px;
  padding: 10px 15px;
  line-height: 22px;
  margin-bottom: 35px;
}
.overdue-img {
  width: 40px;
  height: 32px;
  position: absolute;
  top: 0px;
  right: 0;
}
/deep/ .ant-modal-body {
  min-height: 400px !important;
  max-height: 655px !important;
  overflow: auto;
}
.coupon_box {
  margin-bottom: 24px;
  margin-right: 20px;
  width: 300px;
}
.current {
  display: flex;
  margin-right: 20px;
}
.cursor {
  cursor: pointer;
}
</style>
